summaryrefslogtreecommitdiff
path: root/app/[lng]/partners/(partners)/_document-upload/page.tsx
diff options
context:
space:
mode:
authordujinkim <dujin.kim@dtsolution.co.kr>2025-11-27 09:44:05 +0000
committerdujinkim <dujin.kim@dtsolution.co.kr>2025-11-27 09:44:05 +0000
commit24c19f0193cab4df20510e2764c0d0fe158e3842 (patch)
tree168ff80cf3c9bec667bd0056d3f50722582c151a /app/[lng]/partners/(partners)/_document-upload/page.tsx
parentdaabc02e9ae54f216ada77aa826b349f37c3281a (diff)
parent5ca88c4869be338f4b0e506a679e4dc4e029d7aa (diff)
Merge branch 'dujinkim' of https://github.com/DTS-Development/SHI_EVCP into dujinkim
Diffstat (limited to 'app/[lng]/partners/(partners)/_document-upload/page.tsx')
-rw-r--r--app/[lng]/partners/(partners)/_document-upload/page.tsx154
1 files changed, 154 insertions, 0 deletions
diff --git a/app/[lng]/partners/(partners)/_document-upload/page.tsx b/app/[lng]/partners/(partners)/_document-upload/page.tsx
new file mode 100644
index 00000000..c67a603c
--- /dev/null
+++ b/app/[lng]/partners/(partners)/_document-upload/page.tsx
@@ -0,0 +1,154 @@
+// app/(vendor)/stage-submissions/page.tsx
+import * as React from "react"
+import { searchParamsCache } from "@/lib/vendor-document-list/plant/upload/validation"
+import { StageSubmissionsTable } from "@/lib/vendor-document-list/plant/upload/table"
+import { redirect } from "next/navigation"
+import {
+ Card,
+ CardContent,
+ CardDescription,
+ CardHeader,
+ CardTitle
+} from "@/components/ui/card"
+import { Badge } from "@/components/ui/badge"
+import { getServerSession } from 'next-auth/next'
+import { authOptions } from '@/app/api/auth/[...nextauth]/route'
+import { getStageSubmissions, getProjects, getSubmissionStats } from "@/lib/vendor-document-list/plant/upload/service"
+import db from "@/db/db"
+import { eq } from "drizzle-orm"
+import { vendors } from "@/db/schema"
+
+export default async function StageSubmissionsPage({
+ searchParams,
+}: {
+ searchParams: Promise<Record<string, string | string[] | undefined>>
+}) {
+ // Session 체크
+ const session = await getServerSession(authOptions)
+
+ if (!session?.user?.companyId) {
+ redirect("/partners")
+ }
+
+
+ const vendor = await db.query.vendors.findFirst({
+ where: eq(vendors.id, session.user.companyId),
+ columns: {
+ vendorName: true,
+ vendorCode: true,
+ }
+ })
+
+ const params = searchParamsCache.parse(await searchParams)
+
+ const submissionsPromise = getStageSubmissions(params)
+ const projectsPromise = getProjects()
+ const statsPromise = getSubmissionStats()
+
+ const [submissions, projects, stats] = await Promise.all([
+ submissionsPromise,
+ projectsPromise,
+ statsPromise
+ ])
+
+ return (
+ <div className="container mx-auto py-6 space-y-6">
+ {/* Header */}
+ <div className="flex items-center justify-between">
+ <div>
+ <h2 className="text-2xl font-bold tracking-tight">My Stage Submissions</h2>
+ <p className="text-muted-foreground mt-1">
+ Manage document submissions for your approved stages (SWP)
+ </p>
+ </div>
+ <div className="">
+ {/* <Badge variant="outline" className="gap-1"> */}
+ {/* <span className="font-semibold">Company:</span> */}
+ <span className="font-semibold"> {vendor.vendorName || "Your Company"}</span>
+
+ <p className="text-muted-foreground text-sm">
+ Buyer Approved Documents
+ </p>
+ {/* </Badge> */}
+ </div>
+ </div>
+
+ {/* Stats Cards */}
+ <div className="grid gap-4 md:grid-cols-4">
+ <Card>
+ <CardHeader className="pb-2">
+ <CardDescription>Pending Submissions</CardDescription>
+ </CardHeader>
+ <CardContent>
+ <div className="text-2xl font-bold">
+ {stats.pending}
+ </div>
+ </CardContent>
+ </Card>
+
+ <Card>
+ <CardHeader className="pb-2">
+ <CardDescription>Overdue</CardDescription>
+ </CardHeader>
+ <CardContent>
+ <div className="text-2xl font-bold text-destructive">
+ {stats.overdue}
+ </div>
+ </CardContent>
+ </Card>
+
+ <Card>
+ <CardHeader className="pb-2">
+ <CardDescription>Awaiting Sync</CardDescription>
+ </CardHeader>
+ <CardContent>
+ <div className="text-2xl font-bold text-warning">
+ {stats.awaitingSync}
+ </div>
+ </CardContent>
+ </Card>
+
+ <Card>
+ <CardHeader className="pb-2">
+ <CardDescription>Completed</CardDescription>
+ </CardHeader>
+ <CardContent>
+ <div className="text-2xl font-bold text-success">
+ {stats.completed}
+ </div>
+ </CardContent>
+ </Card>
+ </div>
+
+ {/* Main Table */}
+ <Card>
+ <CardHeader>
+ <CardTitle>Your Submission List</CardTitle>
+ <CardDescription>
+ View and manage document submissions for your company's stages
+ </CardDescription>
+ </CardHeader>
+ <CardContent>
+ <React.Suspense
+ fallback={
+ <div className="flex h-[400px] items-center justify-center">
+ <div className="animate-pulse text-muted-foreground">
+ Loading your submissions...
+ </div>
+ </div>
+ }
+ >
+ <StageSubmissionsTable
+ promises={Promise.all([
+ { data: submissions.data, pageCount: submissions.pageCount },
+ { projects: projects.map(p => ({ id: p.id, code: p.code || "" })) }
+ ])}
+ selectedProjectId={params.projectId}
+
+ />
+ </React.Suspense>
+ </CardContent>
+ </Card>
+ </div>
+ )
+} \ No newline at end of file